<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Map extends CI_Controller {
	
	public function index() { }

	public function getMap($mId) {
		$this->load->model('Model_map');
		$cursor = $this->Model_map->getMap($mId);
		echo json_encode(iterator_to_array($cursor)[$mId]);	
	}

	public function getMaps() {
		$this->load->model('Model_map');
		$cursor = $this->Model_map->getMaps();
		echo json_encode(iterator_to_array($cursor));
	}

	public function addMap() {
		$map = $this->input->post('map');
		$mongoId = new MongoId();
		$mongoId = (string)$mongoId;
		$map['_id'] = $mongoId;
		$this->load->model('Model_map');
		$this->Model_map->insertMap($map);
		print_r($map);

		
	}

}
